import Main from "./main.vue";

interface ISidebarIframeOptions {
  /** 显示页面的地址 */
  url: string;
  /** 标题 */
  title?: string;
  /** 大小 */
  size?: number | string;

  /** 是否可以点击 Model 进行关闭 */
  closeOnClickModal?: boolean;
  /** 关闭前的回调事件，调用 done 进行关闭操作 */
  beforeClose?: (done: () => void) => void;
}

const JuDrawer = (options: ISidebarIframeOptions) => {
  const instance = new Main({
    data: options,
  });
  instance.$mount();

  document.body.appendChild(instance.$el);

  return instance;
};

JuDrawer.show = (options: ISidebarIframeOptions) => JuDrawer(options);

export default JuDrawer;
